﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true" CodeBehind="CadastroClassificacao.aspx.cs" Inherits="Juntae.Admin.Classificacao" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link href="../../../../resources/css/examples.css" rel="stylesheet" type="text/css" />   
    <link href="styles/css/ui-lightness/jquery-ui-1.8.13.custom.css" rel="stylesheet"
        type="text/css" /> 
    <script src="styles/js/jquery-1.5.1.min.js" type="text/javascript"></script>
    <script src="styles/js/jquery-ui-1.8.13.custom.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $("#tabs").tabs();
        });

        var template = '<span style="color:{0};">{1}</span>';

        var change = function (value) {
            return String.format(template, (value > 0) ? "green" : "red", value);
        };

        var pctChange = function (value) {
            return String.format(template, (value > 0) ? "green" : "red", value + "%");
        };

        var startEditing = function (e) {
            if (e.getKey() === e.ENTER) {
                var grid = GridPanel1,
                    record = grid.getSelectionModel().getSelected(),
                    index = grid.store.indexOf(record);

                grid.startEditing(index, 1);
            }
        };

        var afterEdit = function (e) {
            CompanyX.AfterEdit(e.record.data.Id_categoria, e.field, e.originalValue, e.value, e.record.data);
        };
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div id="tabs" style="font-size:12px;">
    <ext:TreeEditor runat="server">
    </ext:TreeEditor>
   <ul>
      <li><a href="#tabs-1">Nova Classificação</a></li>
      <li><a href="#tabs-2">Lista de Classificações</a></li>
   </ul>
   <div id="tabs-1">
        <ext:TextField ID="lblDescricao" runat="server" FieldLabel="Descrição" Note="Categoria" />
        <ext:Button ID="btnAdd" runat="server" Text="Salvar" Icon="Add" >
            <DirectEvents>
                <Click OnEvent="btnSalvar">
                    <EventMask ShowMask="true" />
                </Click>
            </DirectEvents>
        </ext:Button>
   </div>
   <div id="tabs-2"> 
   
    <ext:ResourceManager runat="server" RemoveViewState="true" IDMode="Explicit" />  
        <ext:GridPanel 
            ID="GridPanel1"
            runat="server" 
            Title="Classificações" 
            StripeRows="true"
            TrackMouseOver="true"
            Width="860" 
            Height="200">
            <Store>
                <ext:Store runat="server">
                    <Reader>
                        <ext:JsonReader IDProperty="ID">
                            <Fields>
                                <ext:RecordField Name="" />
                                <ext:RecordField Name="Id_classificacao" Type="Int" />
                                <ext:RecordField Name="Descricao" />
                                
                            </Fields>
                        </ext:JsonReader>
                    </Reader>
                </ext:Store>
            </Store>
            
            <Listeners>
                <KeyDown Fn="startEditing" />
                <AfterEdit Fn="afterEdit" />
            </Listeners>
            <ColumnModel runat="server">
                <Columns>
                    <ext:CommandColumn Width="30">
                        <Commands>
                            <ext:GridCommand Icon="Delete" CommandName="Delete" />
                        </Commands>
                    </ext:CommandColumn>
                    <ext:Column Header="ID" DataIndex="Id_classificacao" Width="30"  />
                    <ext:Column ColumnID="descricao" Width="750" Header="Descrição" DataIndex="Descricao" >
                        <Editor>
                            <ext:TextField runat="server" />
                        </Editor>
                    </ext:Column>
                </Columns>
            </ColumnModel>
            <SelectionModel>
                <ext:RowSelectionModel runat="server" SingleSelect="true" />
            </SelectionModel>
            <DirectEvents>
            <Command OnEvent="Command">
                <ExtraParams>
                    <ext:Parameter Name="id" Value="record.data.Id_classificacao" Mode="Raw" />
                    <ext:Parameter Name="command" Value="command" Mode="Raw" />
                </ExtraParams>
            </Command>
        </DirectEvents>
        </ext:GridPanel>
   </div>
</div>  
<br />
</asp:Content>
